﻿@{
    ViewBag.Title = "MedicalInsuranceCatalogue";
    Layout = "~/Views/Shared/_Index.cshtml";
    var opr = Newtouch.Common.Operator.OperatorProvider.GetCurrent();
}

<ul id="myTab" class="nav nav-tabs">
    <li class="active"><a href="#xz" data-toggle="tab">下载类目录</a></li>
    <li><a href="#cx" data-toggle="tab">查询类目录</a></li>
    @*<li><a href="#zdcx" data-toggle="tab">字典表查询</a></li>
    <li><a href="#yzry" data-toggle="tab">医执人员信息查询</a></li>*@
</ul>
<div id="myTabContent" class="tab-content">
    <div class="tab-pane fade in active" id="xz">
        <form>
            <div class="panel panel-default">
                <table class="form">
                    <tr>
                        <th class="formTitle">目录：</th>
                        <td class="formValue" style="width:220px;">
                            <select id="XZNR" name="XZNR" class="form-control">
                                <option value="0">============请选择===========</option>
                                <option value="1301">【1301】西药中成药目录下载</option>
                                <option value="1302">【1302】中药饮片目录下载</option>
                                <option value="1303">【1303】医疗机构制剂目录下载</option>
                                <option value="1305">【1305】医疗服务项目目录下载</option>
                                <option value="1306">【1306】医用耗材目录下载</option>
                                <option value="1307">【1307】疾病与诊断目录下载</option>
                                <option value="1308">【1308】手术操作目录下载</option>
                                <option value="1309">【1309】门诊慢特病种目录下载</option>
                                <option value="1310">【1310】按病种付费病种目录下载</option>
                                <option value="1311">【1311】日间手术治疗病种目录下载</option>
                                <option value="1313">【1313】肿瘤形态学目录下载</option>
                                <option value="1314">【1314】中医疾病目录下载</option>
                                <option value="1315">【1315】中医证候目录下载</option>

                            </select>
                        </td>
                        <td class="formTitle">版本号：</td>
                        <td class="formValue">
                            <input type="text" id="BBH" class="form-control" value="0" />
                        </td>
                        <td class="formTitle">
                            <input type="button" id="XiaZai" class="btn btn-primary btn-md" value="目录下载" style="width:55px" />

                        </td>
                        <td class="formTitle" style="text-align:right;">药品/项目名称：</td>
                        <td class="formValue">
                            <input type="text" id="mlmc" class="form-control" value="" style="width:105px" />
                        </td>
                        <td class="formTitle">
                            <input type="button" id="btn_cx" class="btn btn-primary btn-md" style="float:left" value="查询" />
                        </td>
                    </tr>
                    <tr>

                        <td class="formValue" style="text-align:left; color:red" colspan="4">
                            <span>
                                备注:首次下载版本号传“0”    操作下载后请等待5-10分钟
                            </span>
                            下载方式:<span>单次<input type="radio" name="rd" value="0" checked="checked"/> 循环<input type="radio" name="rd" value="1" /></span>
                        </td>
                      
                    </tr>
                </table>
            </div>
            <div class="gridPanel" id="gridPanel1">
                <table id="gridList"></table>
                <div id="gridPager"></div>
            </div>
        </form>
    </div>
    <div class="tab-pane fade" id="cx">
        <form>
            <div class="panel panel-default">
                <table class="form">
                    <tr>
                        <th class="formTitle">*目录：</th>
                        <td class="formValue">
                            <select id="btmlcx" name="btmlcx" class="form-control">
                                <option value="0">============请选择===========</option>
                                <option value="1304">【1304】民族药品目录查询</option>
                                <option value="1312">【1312】医保目录信息查询</option>
                                <option value="1316">【1316】医疗目录与医保目录匹配信息查询</option>
                                <option value="1317">【1317】医药机构目录匹配信息查询</option>
                                <option value="1318">【1318】医保目录限价信息查询</option>
                                <option value="1319">【1319】医保目录先自付比例信息查询</option>

                            </select>
                        </td>
                        <td class="formTitle">*当前页数:</td>
                        <td class="formValue">
                            <input type="text" id="pagenum" class="form-control" style="height:26px;width:90px;display:inline" value="" />
                            <input type="button" id="btn_NextPage" class="btn btn-primary btn-md" value="下一页" />
                        </td>
                        <td class="formTitle">*本页数据量:</td>
                        <td class="formTitle">
                            <input type="text" id="pagesize" class="form-control" style="height:16px" value="" />
                        </td>
                        <td class="formTitle">*更新时间:</td>
                        <td class="formValue">
                            <input id="gxsj" type="text" class="form-control input-wdatepicker" style="width:120px; float:left;margin-left:1%;" value="@DateTime.Now.AddDays(-180).ToString("yyyy-MM-dd")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
                        </td>
                    </tr>
					<tr>
						<td class="formTitle">医疗目录编码:</td>
						<td class="formValue">
							<input type="text" id="drugCode" class="form-control" value="" />
						</td>
						<td class="formTitle">通用名称:</td>
						<td class="formValue">
							<input type="text" id="drugName" class="form-control" value="" />
						</td>
						<th class="formTitle">数据来源：</th>
						<td class="formValue">
							<select id="sjly" name="sjly" class="form-control">
								<option value="1">本地数据源</option>
								<option value="2">医保数据源</option>
							</select>
						</td>
						<td class="formTitle">
							<input type="button" id="btn_mlcx" class="btn btn-primary btn-md" value="查询" />
						</td>
						<td class="formValue"></td>
						<td class="formTitle"></td>
						<td class="formValue"></td>
					</tr>
                </table>
            </div>
            <div class="gridPanel" id="gridPanel2" style="width:100%">
                <table id="gridList2"></table>
            </div>
        </form>
    </div>
    <div class="tab-pane fade" id="zdcx">
        <form>
            <div class="panel panel-default">
                <table class="form">
                    <tr>
                        <td class="formTitle">字典类型:</td>
                        <td class="formValue">
                            <input type="text" id="zdtype" class="form-control" value="" />
                        </td>
                        <td class="formTitle" style="padding-right:5px;">父字典键值:</td>
                        <td class="formValue">
                            <input type="text" id="zdparentValue" class="form-control" value="" />
                        </td>
                        <td class="formTitle" style="padding-right:5px;">行政区划:</td>
                        <td class="formValue">
                            <input type="text" id="zdadmdvs" class="form-control" value="" />
                        </td>
                        <td class="formTitle" style="padding-right:5px;">查询日期:</td>
                        <td class="formValue">
                            <input id="zddate" type="text" class="form-control input-wdatepicker" style="width:120px; float:left;margin-left:1%;" value="@DateTime.Now.ToString("yyyy-MM-dd")" onfocus="WdatePicker({ dateFmt: 'yyyy-MM-dd' })" />
                        </td>
                        <td class="formTitle" style="padding-right:5px;">
                            <input type="button" id="btn_zdcx" class="btn btn-primary btn-md" value="查询" style="width:60px;" />
                        </td>
                    </tr>
                </table>
                <div class="gridPanel" id="gridPanel3" style="width:100%">
                    <table id="gridList3"></table>
                </div>
            </div>
        </form>
    </div>

    <div class="tab-pane fade" id="yzry">
        <form>
            @*<div class="panel panel-default">*@
            <table class="form" style="width:350px;">
                <tr>
                    <td class="formTitle">执业人员类型:</td>
                    <td class="formValue">
                        <select id="prac_psn_type" name="prac_psn_type" class="form-control">
                            <option value="">======请选择=====</option>
                            <option value="1">医师</option>
                            <option value="2">护士</option>
                            <option value="3">药师</option>
                            <option value="4">医技人员</option>
                        </select>
                    </td>
                    <td class="formTitle" style="padding-right:5px;">
                        <input type="button" id="btn_yzry" class="btn btn-primary btn-md" value="查询" style="width:60px;" />
                    </td>
                </tr>
            </table>
            <div class="gridPanel" id="gridPanel4" style="width:100%">
                <table id="gridList4"></table>
            </div>
            @*</div>*@
        </form>
    </div>

</div>

    <script type="text/javascript" src="@SiteUrl.GetStaticResourceScriptUrl("~/Content/js/Catalogl.js",false)"></script>
    <script type="text/javascript">

        $(function () {
            $("#pagenum").val(1);
            $("#pagesize").val(100);
        });

        $('#XZNR').change(function () {
            if ($('#XZNR').val()=="0")
            {
                return;
            }
            $("#BBH").val(0);
            $("#mlmc").val("");
            $('#gridList').remove();
            $("#gridPager").remove();
            $("#gbox_gridList").remove();
            $("#gridPanel1").append('<table id="gridList"></table><div id="gridPager"></div>');
            $('#gridList').jqGrid("clearGridData");
            GetVer();
            gridList();
        })

        function GetVer() {
            $.ajax({
                url: "/Settlement/GzybBaseInfo/GetVer",
                dataType: "json",
                async: true,
                data: { tbname: $('#XZNR').val() },
                type: "post",
                success: function (data) {
                    $("#BBH").val(data.bbh);
                },
                error: function (request, error, ex) {
                    $.loading(false);
                    $.modalAlert("获取目录版本号错误：[" + ex + "]", 'error');

                }
            })
        }
        function gridList() {
            var $gridList = $("#gridList");
            var XZNR = $('#XZNR').val();
            $gridList.dataGrid({
                url: "/Settlement/GzybBaseInfo/CatalogueData",
                height: $(window).height() - 160,
                postData: { tbname: XZNR, key: $('#mlmc').val() },
                colModel: mlbh(XZNR),
                pager: "#gridPager",
                sortname: 'VER desc',
                rowNum: '15',
                viewrecords: true
            });

            $("#btn_cx").click(function () {

                $gridList.jqGrid('setGridParam', {
                    postData: { tbname: XZNR, key: $('#mlmc').val() },
                }).trigger('reloadGrid');
            });
        }

        $('#XiaZai').click(function () {
            if($('#XZNR').val()=="0")
            {
                $.modalAlert("请选择需下载的目录", 'warning');
                return;
            }
            setTimeout(function () {
                $.loading(true, '下载目录文件中 请稍等...');
                setTimeout(function () { XiaZai(); }, 50);
            }, 50);
        })

        function XiaZai() {
            var XZNR = $('#XZNR').val();
            var bbh = $('#BBH').val();
            var xzfs = $('input[name=rd]:checked').val();
            $.ajax({
                url: "http://127.0.0.1:33333/api/YiBaoDirectory/DownloadIndex",
                dataType: "json",
                async: false,
                data: { ver: bbh, tradiNumber: XZNR, type: xzfs, czydm: '@(opr.rygh)', czyxm: '@(opr.UserName)' },
                type: "post",
                success: function (data) {
                    var Returndata = eval('(' + data + ')');
                    if (Returndata.infcode == "0") {
                        $("#btn_cx").click();
                        GetVer();
                        $.modalAlert("目录下载成功!", 'success');
                    }
                    else {
                        $.loading(false);
                        if (Returndata.err_msg.indexOf("违反了 PRIMARY KEY 约束") == -1) {
                            $.modalAlert(Returndata.err_msg, "error");
                        }
                        else {
                            $("#btn_cx").click();
                            GetVer();
                            $.modalAlert("已下载至最新版本!", "error");
                        }

                    }

                },
                error: function (request, error, ex) {
                    $.loading(false);
                    $.modalAlert("医保服务(目录下载接口)不可访问：[" + ex + "]", 'error');

                }

            })


        }
        //目录查询类
        $('#btmlcx').change(function () {
            if ($('#btmlcx').val() == "0") {
                return;
            }
            $("#pagenum").val(1);
            $("#drugName").val("");
            $("#drugCode").val("");
            $('#gridList2').remove();
            $("#gbox_gridList2").remove();
            $("#gridPanel2").append('<table id="gridList2"></table>');
            $('#gridList2').jqGrid("clearGridData");
            gridList2();
        })

        function gridList2() {
			var $gridList2 = $("#gridList2");
            var btnMlbh = $("#btmlcx").val();
            $gridList2.newtouchLocalDataGrid({
                height: $(window).height() - 160,
                autowidth: false,
                unwritten: false,
                colModel: mlbh(btnMlbh),
            }, DirectoryQuery());

        }

        $("#btn_mlcx").click(function () {
            if ($('#btmlcx').val() == "0") {
                $.modalAlert("请选择需查询的目录", 'warning');
                return;
            }
            //$('#gridList2').remove();
            //$("#gbox_gridList2").remove();
            //$("#gridPanel2").append('<table id="gridList2"></table>');
            $('#gridList2').jqGrid("clearGridData");
            gridList2();
        });
        $("#btn_NextPage").click(function () {
            $("#pagenum").val(parseInt($('#pagenum').val())+1);
            $('#gridList2').jqGrid("clearGridData");
            gridList2();
        });

        //目录查询返回值
        function DirectoryQuery()
		{
			var type = $('#sjly').val();
            var ResultData;
            var drug_prodname = $("#drugName").val();
            var drug_Code = $("#drugCode").val();

            if (drug_Code || drug_prodname)
            {
                $("#pagenum").val(1);
            }
            var updt_time = $('#gxsj').val();
            var page_num = $('#pagenum').val();
            var page_size = $('#pagesize').val();
            var tradiNumber = $("#btmlcx").val();
            var dataReq = { updt_time: updt_time, page_num: page_num, page_size: page_size, tradiNumber: tradiNumber, vali_flag: "1", operatorId: '@(opr.rygh)', operatorName: '@(opr.UserName)' };
            if (tradiNumber = "1304")
            {
                dataReq.med_list_codg = drug_Code;
                dataReq.drug_genname = drug_prodname;
            }
            if (tradiNumber = "1312") {
                dataReq.hilist_code = drug_Code;
                dataReq.hilist_name = drug_prodname;
            }
            if (tradiNumber = "1316")
            {
                dataReq.medins_list_codg = "";
                dataReq.hilist_code = drug_Code;
            }
            if (tradiNumber = "1317") {
                dataReq.med_list_codg = drug_Code;
                dataReq.medins_list_name = drug_prodname;
            }
            if (tradiNumber = "1318") {
                dataReq.med_list_codg = drug_Code;
            }
            if (tradiNumber = "1319") {
                dataReq.hilist_code = drug_Code;
            }
            $.loading(true, '数据加载中...');
            $.ajax({
                type: "POST",
                url: "http://127.0.0.1:33333/api/YiBaoDirectory/GetCatalogData",
                dataType: "json",
                data:dataReq,
                async: false,
                success: function (data) {
                    ResultData = eval('(' + data + ')');
                    if (ResultData.infcode == "0") {
                        ResultData = ResultData.output.data;
                    }
                    else {
                        $.loading(false);
                        $.modalAlert(ResultData.err_msg, "error");
                    }
                },
                error: function (request, error, ex) {
                    $.loading(false);
                    $.modalAlert("医保服务(目录查询接口)不可访问：[" + ex + "]", 'error');

                }
            });
            $.loading(false);
            return ResultData;
        }

        //字典表查询
        $("#btn_zdcx").click(function () {
            var type = $('#zdtype').val();
            if (!type) {
                $.modalAlert("字典类型不能为空！", 'warning');
                return false;
            }
            var parentValue = $('#zdparentValue').val();
            if (!parentValue) {
                $.modalAlert("父字典键值不能为空！", 'warning');
                return false;
            }
            var admdvs = $('#zdadmdvs').val();
            if (!admdvs) {
                $.modalAlert("行政区划不能为空！", 'warning');
                return false;
            }
            var date = $('#zddate').val();
            if (!date) {
                $.modalAlert("查询日期不能为空！", 'warning');
                return false;
            }
            $('#gridList3').remove();
            $("#gbox_gridList3").remove();
            $("#gridPanel3").append('<table id="gridList3"></table>');
            $('#gridList3').jqGrid("clearGridData");
            gridList3();

        });

        function gridList3() {
            var $gridList3 = $("#gridList3");
            $gridList3.newtouchLocalDataGrid({
                height: $(window).height() - 160,
                autowidth: false,
                unwritten: false,
                // width: $("#formPat2").width() - 10,
                //caption: captionCon,
                colModel: mlbh("1901"),
            }, DictionaryTable());

        }


        //字典表查询返回值
        function DictionaryTable() {
            var type = $('#zdtype').val();
            var parentValue = $('#zdparentValue').val();
            var admdvs = $('#zdadmdvs').val();
            var date = $('#zddate').val();
            //var valiFlag = $('#zdvaliFlag').val();
            var ResultData;
            $.loading(true, '数据加载中...');
            $.ajax({
                type: "POST",
                url: "http://127.0.0.1:33333/api/YiBao/DictionaryTable",
                dataType: "json",
                data: { type: type, parentValue: parentValue, admdvs: admdvs, date: date, tradiNumber: "1901", vali_Flag: "1", operatorId: operatorId, operatorName: operatorName },
                //data: { updt_time: "2021-06-26", page_num: "1", page_size: "100", tradiNumber: "1304", drug_prodname: "", vali_flag: "1", operatorId: operatorId, operatorName: operatorName},
                async: false,
                success: function (data) {
                    //console.info(data);
                    ResultData = eval('(' + data + ')');
                    ResultData = ResultData.output.list;
                },
                error: function () {
                    $.loading(false);
                    $.modalAlert("服务不可访问", 'warning');
                }
            });
            $.loading(false);
            return ResultData;
        }


        $('#prac_psn_type').change(function () {
            newtouch_event_f4();

            $('#gridList4').remove();
            $("#gridPager4").remove();
            $("#gbox_gridList4").remove();
            $("#gridPanel4").append('<table id="gridList4"></table><div id="gridPager4"></div>');
            $('#gridList4').jqGrid("clearGridData");
            MedicalExecutive();
        })


        //医执人员信息查询
        $("#btn_zdcx").click(function () {
            $('#gridList4').remove();
            $("#gbox_gridList4").remove();
            $("#gridPanel4").append('<table id="gridList4"></table>');
            $('#gridList4').jqGrid("clearGridData");
            MedicalExecutive();
        });
        function MedicalExecutive() {
            var $gridList4 = $("#gridList4");
            $gridList4.newtouchLocalDataGrid({
                height: $(window).height() - 160,
                autowidth: false,
                unwritten: false,
                // width: $("#formPat2").width() - 10,
                //caption: captionCon,
                colModel: [
                    { label: '人员证件类型', name: 'psn_cert_type', width: 100, align: 'left' },
                    { label: '证件号码', name: 'certno', width: 100, align: 'left' },
                    { label: '执业人员自编号', name: 'prac_psn_no', width: 100, align: 'left' },
                    { label: '执业人员代码', name: 'prac_psn_code', width: 100, align: 'left' },
                    { label: '执业人员姓名', name: 'prac_psn_name', width: 100, align: 'left' },
                    { label: '执业人员分类', name: 'prac_psn_type', width: 60, align: 'left' },
                    { label: '执业人员资格证书编码', name: 'prac_psn_cert', width: 60, align: 'left' },
                    { label: '执业证书编号', name: 'prac_cert_no', width: 60, align: 'left' },
                    { label: '医保医师标志', name: 'hi_dr_flag', width: 60, align: 'left' },
                    { label: '开始时间', name: 'begntime', width: 100, align: 'left' },
                    { label: '结束时间', name: 'endtime', width: 100, align: 'left' },
                    { label: '变更原因', name: 'chg_rea', width: 100, align: 'left' }
                ]
            }, MedicalExecutiveData());

        }
        function MedicalExecutiveData() {
            debugger
            var prac_psn_type = $('#prac_psn_type').val();
            var ResultData;
            $.loading(true, '数据加载中,请稍后...');
            $.ajax({
                type: "POST",
                url: "http://127.0.0.1:33333/api/YiBao/MedicalExecutive",
                dataType: "json",
                data: { prac_psn_type: prac_psn_type, operatorId: operatorId, operatorName: operatorName },
                async: false,
                success: function (data) {
                    //console.info(data);
                    ResultData = eval('(' + data + ')');
                    ResultData = ResultData.output.feedetail;
                },
                error: function () {
                    $.loading(false);
                    $.modalAlert("服务不可访问", 'warning');
                }
            });
            $.loading(false);
            return ResultData;
        }


    </script>


